//
//  RankBottomView.m
//  WanCaiC8
//
//  Created by tangang on 2018/4/25.
//  Copyright © 2018年 tangang. All rights reserved.
//

#import "RankBottomView.h"

@implementation RankBottomView{
    UIImageView *headImage;
    QXLable     *labName;
    QXLable     *labRank;
    UIButton    *btneExceptional;
}

- (instancetype)init{
    if (self=[super init]) {
        self.backgroundColor=[UIColor whiteColor];
        headImage=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"avatar"]];
        headImage.layer.masksToBounds=YES;
        headImage.layer.cornerRadius=23.0;
        [self addSubview:headImage];
        [headImage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).with.offset(10);
            make.centerY.equalTo(self);
            make.size.mas_equalTo(CGSizeMake(46, 46));
        }];
        
        labName=[[QXLable alloc]initTitle];
        labName.textColor=NAVCOLOR;
        [self addSubview:labName];
        [labName mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(headImage.mas_right).with.offset(13);
            make.top.equalTo(headImage);
        }];
        
        labRank=[[QXLable alloc]init];
        [self addSubview:labRank];
        [labRank mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(headImage.mas_right).with.offset(13);
            make.bottom.equalTo(headImage);
        }];
        
        btneExceptional =[[UIButton alloc]init];
        [btneExceptional setImage:[UIImage imageNamed:@"master_integral"] forState:UIControlStateNormal];
        [btneExceptional setTitleColor:DEFAULTORANGECOLOR forState:UIControlStateNormal];
        [btneExceptional setTitle:@" 200" forState:UIControlStateNormal];
        btneExceptional.contentHorizontalAlignment=
        UIControlContentHorizontalAlignmentRight;
        [btneExceptional.titleLabel setFont:[UIFont systemFontOfSize:18]];
        [self addSubview:btneExceptional];
        [btneExceptional mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(headImage);
            make.right.equalTo(self).with.offset(-10);
            make.size.mas_equalTo(CGSizeMake(200, 30));
        }];
        UIView *line=[[UIView alloc]init];
        line.backgroundColor=DEFAULTBGCOLOR;
        [self addSubview:line];
        [line mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.top.equalTo(self);
            make.height.mas_equalTo(@.7);
        }];
    }
    return self;
}

- (void)setRankingUserModel:(RankingUserModel *)rankingUserModel{
    _rankingUserModel=rankingUserModel;
    if (rankingUserModel.Rank==0) {
        labRank.text=@"当前排名：暂无";
    }else{
        labRank.text=[NSString stringWithFormat:@"当前排名：%ld",rankingUserModel.Rank];
    }
    [headImage sd_setImageWithURL:[NSURL URLWithString:[UserModel userModel].Avater] placeholderImage:[UIImage imageNamed:@"avatar"]];
    labName.text=rankingUserModel.NickName;
    [btneExceptional setTitle:[NSString stringWithFormat:@" %ld",rankingUserModel.Number] forState:UIControlStateNormal];
}

@end
